@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-11">
            <div class="card">
                <div class="card-header">
                    <a href='/home'>个人中心</a>
                    &nbsp
                    <a href="/customerlist">查看全部</a>
                    &nbsp
                    @if (!empty($search_userid))
                    <a href="/customerlist?userid={{$search_userid}}&&verify=未通过">未通过</a>
                    &nbsp
                    <a href="/customerlist?userid={{$search_userid}}&&verify=通过">通过</a>
                    @else
                    <a href="/customerlist?verify=未通过">未通过</a>
                    &nbsp
                    <a href="/customerlist?verify=通过">通过</a>
                    @endif
                    &nbsp
                    <label>共找到{{$count}}条记录</label>
                </div>
                <table id="ddtable"class="table table-condensed table-responsive table-bordered ">
                    <tr>
                        <td class='lead'>姓名</td>
                        <td class='lead'>手机</td>
                        <td class='lead'>身份证</td>
                        <td class='lead'>业务员</td>
                        <td class='lead'>状态</td>
                        <td class='lead'>时间</td>
                        <td class='lead'>审核</td>
                        <td class='lead'>备注</td>
                    </tr>
                    @if ($customers!=null)
                    <tr>
                        @foreach ($customers as $customer)
                        <td>{{$customer->name}}</td>
                        <td>{{$customer->phone}}</td>
                        <td>{{$customer->idcard}}</td>
                        @if (Auth::user()->role=='admin')
                        <td><a href='/customerlist?userid={{$customer->userid}}'>{{$customer->username}}</a></td>
                        @else
                        <td>{{$customer->username}}</td>
                        @endif
                        <td>{{$customer->verify}}</td>
                        <td>{{$customer->created_at}}</td>
                        @if (Auth::user()->role=='admin')
                            <td><a href="/customerverify?id={{$customer->id}}&&verify=1">通过</a>
                            <a href="/customerverify?id={{$customer->id}}&&verify=2">未通过</a></td>
                            <td><input type='text' id='remark{{$customer->id}}' value='{{$customer->remark}}'/><button onclick='modifyremark({{$customer->id}})'>提交</button></td>
                            <script>
                            function modifyremark(id){
                                var remark=document.getElementById("remark"+id).value;
                                var senddata='remark='+remark+'&&id='+id;
                                $.ajax({
                                type:'get',
                                    url:'/customerverify',
                                    data:senddata,
                                    success:function(data)
                                    {
                                        //alert('备注成功');
                                    }
                                });
                            }
                            </script>
                        @endif
                    </tr>
                    @endforeach
                </div>
                </table>
                @endif
        </div>
    </div>
    {{ $customers->appends(['userid'=>$search_userid,'verify'=>$search_verify])->links() }}  
</div>
</div>
</div>
</div>
@endsection
